#include "pch.h"
#include "db_exception.h"
#include "db_interface_mysql.h"
#include "db_interface.h"
#include "mysqld_error.h"
#include "errmsg.h"


//-------------------------------------------------------------------------------------
DBException::DBException(DBInterface* dbi) :
			errStr_(mysql_error(static_cast<DBInterfaceMysql*>(dbi)->mysql())),
			errNum_(mysql_errno(static_cast<DBInterfaceMysql*>(dbi)->mysql()))
{
}

//-------------------------------------------------------------------------------------
DBException::~DBException() throw()
{
}

//-------------------------------------------------------------------------------------
bool DBException::shouldRetry() const
{
	return (errNum_== ER_LOCK_DEADLOCK) ||
			(errNum_ == ER_LOCK_WAIT_TIMEOUT);
}

//-------------------------------------------------------------------------------------
bool DBException::isLostConnection() const
{
	return (errNum_ == CR_SERVER_GONE_ERROR) ||
			(errNum_ == CR_SERVER_LOST);
}


// db_exception.cpp
